import {createPinia, defineStore} from 'pinia'
import piniaPluginPersistedState from 'pinia-plugin-persistedstate'
const InstallStore = createPinia();
const UserModel = ()=>{
    return {
        Id: null,
        userName: "",
        isSupper: null,
        role: null,
        phone: "",
        email: "",
        name: "",
        jobNum: "",
        cardId: null,
        fansNum: 0,
        collectionNum: 0,
        Academy: {
            id: null,
            name: "",
            createTime: ""
        },
        createTime: ""
    }
}
const useUserStore = defineStore('user', {
    state: () => ({user:UserModel()}),
    actions: {
         set(user) {
             this.user = user
        },
         clear() {
             console.log('============' ,UserModel())
            this.user =  UserModel()
        }
    },
    persist: {
        key: 'STORE_USER',
        storage: window.localStorage,
        paths: ['user'],
    },
})
InstallStore.use(piniaPluginPersistedState)

export {InstallStore};

export default useUserStore
